var weekdays = ["天","一","二","三","四","五","六"];
/*
1.显示当前时间
设置一秒后再调用 getTimes()
2.显示当前时间
设置一秒后再调用 getTimes()
*/
window.onload = getTimes;
function getTimes(){
var d = new Date();
var yy = d.getFullYear();
var mo = d.getMonth()+ 1;
var dd = d.getDate();
var hh = d.getHours();
var mi = d.getMinutes();
var ss = d.getSeconds();
if (mo<10)
{
mo = '0' + mo;
}
if (dd<10)
{
dd = '0' + dd;
}
if (hh<10)
{
hh = '0' + hh;
}
if (mi<10)
{
mi = '0' + mi;
}
if (ss<10)
{
ss = '0' + ss;
}
var str =yy + "-" + mo + "-" + dd + " 星期" + weekdays[d.getDay()];
str += " " + hh + ":" + mi + ":" + ss;
document.getElementById("time").innerHTML = str;
setTimeout("getTimes()",1000);
}
function getWeekDay(day){
switch(day)
{
case 0:
return "天"
case 1:
return "一"
case 2:
return "二"
case 3:
return "三"
case 4:
return "四"
case 5:
return "五"
case 6:
return "六"
}
}